/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bml.architect.kafka;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.concurrent.ListenableFuture;

import java.util.concurrent.ExecutionException;

/**
 * @author: baiml
 * @Title: Client
 * @ProjectName: 作业管理平台
 * @Depart 软件事业部
 * @Description:
 * @date: 2021/11/18 14:17
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class Client {


    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @Autowired
    private KafkaProperties kafkaProperties;


    @Test
    public void send() throws ExecutionException, InterruptedException {
        String key = "123456";
        String mes = "path=/dolphinscheduler/nodes/agents/server/192.168.11.143:29100\n" +
                "[INFO] 2021-11-18 14:06:45.578 org.apache.dolphinscheduler.pollservice.PollService:[145] - listener node path change path=/dolphinscheduler/nodes/worker/default/192.168.11.143:1234\n" +
                "[INFO] 2021-11-18 14:06:50.856 org.apache.dolphinscheduler.pollservice.PollService:[145] - listener node path change path=/dolphinscheduler/nodes/master/192.168.11.143:5678\n" +
                "[INFO] 2021-11-18 14:06:52.075 org.apache.dolphinscheduler.pollservice.PollService:[145] - listener node path change ";
        ListenableFuture<SendResult<String, String>> test = kafkaTemplate.send("test", key, mes);

        SendResult<String, String> stringStringSendResult = test.get();
        System.out.println(stringStringSendResult);


    }



}
